<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>${resource.title}</title>
    <link rel="stylesheet" href="../css/resource-show.css">
    <link rel="stylesheet" href="../css/layui.css">
    <link rel="stylesheet" href="../css/resource-detail.css">
    <script type="text/javascript" src="../js/jquery.js"></script>
    <script type="text/javascript" src="../js/space-resource-show.js"></script>
    <script type="text/javascript" src="../js/comment.js"></script>
    <script type="text/javascript" charset="utf-8" src=" ../ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src=" ../ueditor/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src=" ../ueditor/lang/zh-cn/zh-cn.js"></script
    <script type="text/javascript" charset="utf-8" src=" ../ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="  ../ueditor/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="  ../ueditor/lang/zh-cn/zh-cn.js"></script>

</head>

<body>
<!--**************顶部导航****************-->
<%@include file="../jsp/common/nav.jsp"%>
<!--**************左侧导航****************-->
<%@include file="../jsp/common/sidebar-scroll.jsp"%>
<!--***************右侧发布资源界面*******************-->
<div class="right">
    <!--标题导航-->
    <div class="resource-nav">
        <span class="resource-nav-title"><a href="/index/main">学习空间</a></span>
        >
        <span class="resource-nav-title"><a href="/index/space-main?space_id=${space.id}&name=${space.name}">${space.name}</a></span>
        >
        <span class="resource-nav-title"><a href="/resource/space-resource">资源区</a></span>
        >
        <span>${resource.title}</span>
    </div>
    <!--资源标题-->
    <div class="resource-title">
        <h2>${resource.title}</h2>
        <div class="resource-t">
            <span class="resource-author">${resource.author}</span>
            <span class="resource-time"><img src="../images/time.png" width="15px" height="15px"/><fmt:formatDate value="${resource.createdate}" pattern="yyyy年M月dd日"/></span>
            <span class="resource-update"><a href="/resource/update?id=${resource.id}">编辑</a></span>
            <span class="resource-del"><a href="/resource/deleteByResource?id=${resource.id}">删除</a></span>
        </div>

        <div class="label">
            <span class="la">${resource.label}</span>
        </div>

        <div class="resource-content">
            <span>${resource.content}</span>
        </div>

        <c:if test="${not empty reAndDolist}">
        <div class="list">
            <div class="top">
                <span class="resource-name">附件名</span>
                <span class="writer">上传者</span>
                <span class="time">上传时间</span>
                <span class="size">附件大小</span>
                <span class="count">下载次数</span>
                <span class="caozuo">操作</span>
            </div>
            <c:forEach items="${reAndDolist}" var="list">
            <div class="bottom">
                <span class="resource-name">${list.filename}</span>
                <span class="writer">${resource.author}</span>
                <span class="time"><fmt:formatDate value="${list.createdate}" pattern="yyyy年M月dd日"/></span>
                <span class="size">${list.filesize}</span>
                <span class="count">${list.downloadcount}</span>
                <span class="caozuo">
                    <a href="/resource/deleteFile?id=${list.id}&resource_id=${resource.id}">删除</a>
                    <a href="/resource/download?id=${list.id}&filename=${list.filename}&downloadcount=${list.downloadcount}">下载</a>
                </span>
            </div>
            </c:forEach>
            </c:if>
        </div>

        <!-----话题评论信息----->
        <div class="resource-comment-info">
            <!-- 留言的表单 -->
            <form class="layui-form" action="/resource/goToComment" method="post" style="width:90%;">
                <input type="hidden" name="resource_id" value="${resource.id}"/>
                <input type="hidden" name="author_id" value="${sessionScope.user.id}"/>
                <div class="layui-input-block" style="margin-left: 0;">
                    <textarea placeholder="欢迎进行评论" name="content" class="layui-textarea" style="height: 150px;"></textarea>
                </div>
                <br/>
                <div class="layui-input-block" style="text-align:left;right: 0;">
                    <input type="submit" class="layui-btn" value="评论">
                </div>
            </form>
            <br/>
            <!-- 留言信息列表展示 -->

            <!--评论内容-->
            <c:forEach items="${commentList}" var="comment">
                <div class="comment-item" id="item1">
                    <div class="member-info">
                        <span><img src="../images/4.jpg" /></span>
                        <span class="member-name">
                                <a href="/users/user-dongtai?id=${comment.user.id}" >${comment.user.username}</a>
                        </span>
                        <span class="createTime">创建于：<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${comment.createdate}" /></span>
                        <span class="edit"><a href="/resource/deleteComment?comment_id=${comment.id}&resource_id=${resource.id}">删除</a></span>
                        <span class="reply"><a href="javascript:void(0)" onclick="replyBtn(this)">回复</a></span>
                    </div>
                    <div class="comment-info">
                            ${comment.content}
                        <!---回复列表--->
                        <c:forEach items="${replyList}" var="reply">
                            <c:if test="${comment.id==reply.comment.id}">
                                <div class="comment-item">
                                    <div class="member-info">
                                        <span><img src="../images/4.jpg" /></span>
                                        <span class="member-name">
                                            <a href="/users/user-dongtai?id=${reply.author.id}" >${reply.author.username}</a>
                                        回复<a href="/users/user-dongtai?id=${reply.user.id}">@${reply.user.username}</a>
                                    </span>
                                        <span class="createTime">
                                    回复时间：<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${reply.createdate}"/>
                                    </span>
                                        <span class="edit"><a href="/resource/deleteReply?reply_id=${reply.id}&resource_id=${resource.id}">删除</a></span>
                                        <span class="reply"><a href="javascript:void(0)" onclick="replyBtn(this)">回复</a></span>
                                    </div>
                                    <div class="comment-info">
                                            ${reply.content}
                                    </div>
                                </div>

                                <form class="layui-reply-form" action="/resource/reply?comment_id=${comment.id}&resource_id=${resource.id}" method="post" style="width:90%;">
                                    <div class="layui-input-block" style="margin-left: 0;">
                                        <input type="hidden" name="member_id" value="${reply.author.id}">
                                        <textarea name="content" placeholder="请输入你的留言" class="layui-reply-textarea" style="height:50px;"></textarea>
                                    </div>
                                    <br/>
                                    <div class="layui-input-block" style="text-align:left;right: 0;">
                                        <input type="button" class="layui-recover" onclick="recover()" value="取消">
                                        <input type="submit" class="layui-reply-btn" value="回复">
                                    </div>
                                </form>
                            </c:if>
                        </c:forEach>
                    </div>
                </div>

                <form class="layui-reply-form" action="/resource/reply?comment_id=${comment.id}&resource_id=${resource.id}" method="post" style="width:90%;">
                    <div class="layui-input-block" style="margin-left: 0;">
                        <input type="hidden" name="member_id" value="${comment.user.id}">
                        <textarea placeholder="请输入你的留言" name="content" class="layui-reply-textarea" style="height:50px;"></textarea>
                    </div>
                    <br/>
                    <div class="layui-input-block" style="text-align:left;right: 0;">
                        <input type="button" class="layui-recover" onclick="recover()" value="取消">
                        <input type="submit" class="layui-reply-btn" value="回复">
                    </div>
                </form>
            </c:forEach>
    </div>
</div>
</body>
</html>
